package com.prs.crm.domain.hr;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import com.prs.crm.domain.FlowCodeEntity;
import com.prs.crm.domain.sys.Code;
import com.prs.crm.domain.sys.Menu;
import com.prs.crm.domain.sys.Module;

@Entity
@Table(name="hr_role")
public class Role extends FlowCodeEntity{
	
	private static final long serialVersionUID = 1L;
	
	@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
	private Integer id;
	private String rolecode;
	private String name;
	private String remark;
	/**
	 * 114
	 */
	private String jud;
	/**
	 * 商家过滤
	 */
	private String busJud;
	@ManyToOne
	private RoleType type;
	@ManyToMany(fetch= FetchType.LAZY)
	private Set<Module> modules;
	@ManyToMany(fetch= FetchType.LAZY)
	private Set<Menu> menus;
	
	@OneToMany(mappedBy="role")
	private Set<Person> persons;
	
//	@OneToOne(fetch=FetchType.LAZY,mappedBy="role")
//	private Code code;


	private Integer state;
	private String tableName;
	private String baseName;
	@Lob
	private String allfieldname;
	public Integer getState() {
		return state;
	}
	public void setState(Integer state) {
		this.state = state;
	}
	public String getTableName() {
		return tableName;
	}
	public void setTableName(String tableName) {
		this.tableName = tableName;
	}
	public String getBaseName() {
		return baseName;
	}
	public void setBaseName(String baseName) {
		this.baseName = baseName;
	}
	public String getAllfieldname() {
		return allfieldname;
	}
	public void setAllfieldname(String allfieldname) {
		this.allfieldname = allfieldname;
	}
	public Set<Person> getPersons() {
		return persons;
	}
	public void setPersons(Set<Person> persons) {
		this.persons = persons;
	}
	public static long getSerialVersionUID() {
		return serialVersionUID;
	}
	public Set<Module> getModules() {
		return modules;
	}
	public void setModules(Set<Module> modules) {
		this.modules = modules;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public Integer getId() {
		return id;
	}
	
	public String getRolecode() {
		return rolecode;
	}
	public void setRolecode(String rolecode) {
		this.rolecode = rolecode;
	}
	
public String getBusJud() {
		return busJud;
	}
	public void setBusJud(String busJud) {
		this.busJud = busJud;
	}
public String getJud() {
		return jud;
	}
	public void setJud(String jud) {
		this.jud = jud;
	}
	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	//	public Code getCode() {
//		return code;
//	}
//	public void setCode(Code code) {
//		this.code = code;
//	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getRemark() {
		return remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	public void setType(RoleType type) {
		this.type = type;
	}
	public RoleType getType() {
		return type;
	}
	
	public void setMenus(Set<Menu> menus) {
		this.menus = menus;
	}
	public Set<Menu> getMenus() {
		return menus;
	}
	
	public void addModule(Module  module)
	{
		if (modules==null)
		{
			modules = new HashSet<Module>();
		}
		modules.add(module);
	}
	
	public void addMenu(Menu menu)
	{
		if (menus==null)
		{
			menus = new HashSet<Menu>();
		}
		menus.add(menu);
	}

}
